#!/usr/bin/env bash
# 安装 kubeadm 脚本
set -x

sudo swapoff -a # 关闭交换区域
BR_FLAG=$(lsmod | grep br_netfilter)
if [ -z $BR_FLAG ]; then
echo 'br_netfilter is not installed!'
exit 1
fi
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg # 获取密钥
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list # 获取源
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl  # apt 安装
